var sele = GetRequest();
//var cql = "update gouwuche set num='2' where  objectId='58cce8f4ac502e00589573f1' and id=2";
//AV.Query.doCloudQuery(cql).then(function(data) {
//	// results 即为查询结果，它是一个 AV.Object 数组
//	var results = data.results;
//	console.log(1111111111111)
//}, function(error) {
//	console.log(error)
//});
//console.log(122)

if(sele != "*") {
	var query = new AV.Query('Product');
	query.equalTo('type', sele);
	query.find().then(function(results) {
		console.log(results);
		$(".showlike:first").html("");
		for(var i = 0; i < results.length; i++) {
			var src = results[i].attributes.image.split(";");
			var str = '<div class="showlike_item"data-id = "' + results[i].attributes.id + '"><p>';
			str += '<a href="javascript:;"><img src="' + src[0] + '" /></a></p>';
			var title = results[i].attributes.title;
			str += '<p class="f14 h40">' + title + '</p>';
			str += '<p><span class="fb f20">' + results[i].attributes.price + '</span></p>';
			$(".showlike").append(str);
		}
		$(".showlike .showlike_item").one("click", function() {
			Todetail(this);
		}); 
	}, function(error) {});
} else {
	var query = new AV.Query('Product');
	query.find().then(function(results) {
		console.log(results);
		var lis = $(".zhui-fenlei>ul>li"); 
//		console.log(lis.length)
        for(var i = 0; i < lis.length; i++) {
        	if (i == 0 || i == 9|| i == 10|| i == 19|| i == 20|| i == 29) {
        		continue;
        	}
			lis[i].children[0].href = "javascript:;"
			lis[i].children[0].setAttribute("href", "shangpinxiangqing_dj.html?id="+results[i].attributes.id);
			lis[i].children[2].children[0].setAttribute("href", "shangpinxiangqing_dj.html?id="+results[i].attributes.id);
			var src = results[i].attributes.image.split(";");
//			console.log(lis[i].children[1].children[0].innerHTML);
//			console.log(lis[i].children[3].children[0].innerHTML );
//			console.log(lis[i].children[2].children[0].innerHTML);
			lis[i].children[0].children[0].src = src[0];
			lis[i].children[2].children[0].innerHTML = results[i].attributes.title;
			lis[i].children[1].children[0].innerHTML = results[i].attributes.price;
		}
		
		$(".shopright").one("click", function() {
			Todetail(this);
		});
		$(".showbao_item div").one("click", function() {
			Todetail(this);
		});
	});
}

function Todetail(t) {
	var id = t.getAttribute("data-id");
	location.href = "shangpinxiangqing_dj.html?id=" + id;
}